using System.Collections.Generic;
using Entity;
using Utils;

namespace Mapper
{
    class EffectMapper
    {
        public EffectMapper()
        {
            MySQLUtil.CreateConnection();
        }

        public List<Effect> GetEffectByCardId(long cardId)
        {
            return MySQLUtil.SelectData<Effect>($"select effect.* , rel.launchTime , rel.effectParams from card , effect , card_effect_rel rel where card.cardId = {cardId} and card.cardId = rel.cardId and rel.effectId = effect.effectId");
        }

        public List<Effect> GetEffectByLaunchTimeAndCardId(string launchTime , long cardId)
        {
            return MySQLUtil.SelectData<Effect>($"select effect.* , rel.launchTime , rel.effectParams from card , effect , card_effect_rel rel where card.cardId = {cardId} and card.cardId = rel.cardId and rel.effectId = effect.effectId and rel.launchTime = '{launchTime}'");
        }

        public void CloseConnection()
        {
            MySQLUtil.Close();
        }
    }
}

